package cn.hairui.blog.controller;

import cn.hairui.blog.constant.PubConstant;
import cn.hairui.blog.model.WebInfo;
import cn.hairui.blog.service.LinkService;
import cn.hairui.blog.service.WebInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * <h2>请添加说明
 * </h2>
 * <ol>请添加详细说明
 * </ol>
 *
 * <h2>修改历史
 * </h2>
 * <ol>如有修改，请添加修改历史
 * </ol>
 *
 * </p>
 *
 * @author laoganbu
 * @version V1.0
 * @date 2019/8/26 14:54
 */
@Controller
public class LinkController {

    @Autowired
    private WebInfoService webInfoService;
    @Autowired
    private LinkService linkService;

    @RequestMapping(value = "link")
    public String link(HttpServletRequest request, Model model) {
        WebInfo webInfo = webInfoService.find(PubConstant.MY_INFO_ID);
        model.addAttribute("webinfo", webInfo);

        List<Map> linkList = linkService.list();
        model.addAttribute("links", linkList);
        return "link";
    }
}
